<include file="Public/header" title="忘记密码"/>
    <article class="load">
        <img src="__PUBLIC__/home/images/logo.png" />
        <div class="data">
            <form id="dataForm">
                <input type="tel" name="mobile_phone" placeholder="请输入手机号"/>
                <div class="get-code flex-justify">
                    <input type="text" name="smscode" placeholder="请输入验证码">
                    <input type="button" id="sendCode" value="获取验证码" />
                </div>
                <input type="password" name="password" placeholder="请输入新密码"/>
                <input type="password" name="repassword" placeholder="请确认密码"/>
                <a href="javascript:void(0)" id="saveBtn">重置密码</a>
            </form>
            <div class="load-account">
                记得密码<a href="{:U('Login/index')}">去登录</a>
            </div>
        </div>
    </article>
<script>
$(function(){
	var is_send = false;
	//倒计时
	var timer = function (time){
		time = parseInt(time);
		if(time<=0){
			is_send = false;
			$('#sendCode').val("获取验证码");
		}else{
			$('#sendCode').val("已发送"+time+"s");
			setTimeout(function(){timer(--time);},1000);
		}
	}
	$('#sendCode').click(function(){
		if(is_send){
			return false;
		}else{
			is_send = true;
		}
		var telephone = $.trim($('input[name=mobile_phone]').val());
		if(!telephone.match(/^[1][358][0-9]{9}$/)){
			layer.msg('手机号为空或格式有误');
			is_send = false;
			return false;
		}
		$.post(
			"{:U('sendCode')}",
			{telephone:telephone},
			function(data){
				if(data.status == '1'){
					timer(60);
				}else{
					layer.msg(data.info);
					is_send = false;
				}
			}
		);
	})
	$('#saveBtn').click(function(){
		$.post(
			"{:U('savePwd')}",
			$('#dataForm').serializeArray(),
			function(data){
				if(data.status == '1'){
					layer.msg(data.info);
					setTimeout("location.href = '"+data.url+"'",1000);
				}else{
					layer.msg(data.info)
				}
			}
		)
	})
})
</script>
<include file="Public/footer"/>


